define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'rush.schedule/index',
        add_url: 'rush.schedule/add',
        edit_url: 'rush.schedule/edit',
        delete_url: 'rush.schedule/delete',
        export_url: 'rush.schedule/export',
        modify_url: 'rush.schedule/modify',
        sync: 'rush.schedule/sync',
        access_url: 'rush.schedule/access',
        download: 'rush.schedule/download',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh','add',
                    [{
                        text: '推送',
                        url: init.sync,
                        method: 'request',
                        auth: 'sync',
                        class: 'layui-btn layui-btn-danger layui-btn-sm',
                        icon: 'fa fa-plus ',
                        extend: 'data-full="true"',
                    }],
                ],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: '场次ID'},
                    {field: 'name', title: '抢购场次名称'},
                    {field: 'bucket_name', title: '所属分仓'},
                    {field: 'starttime', title: '开始时间'},
                    {field: 'endtime', title: '结束时间'},
                    {field: 'state', title: '状态',templet: function(d){if(d.state == 1){return "正常"}else{return '暂停'}}},
                    {field: 'tip', title: '提示'},
                    {width: 250, title: '操作',
                    templet: function (row) {
                        return ea.table.tool(row, {
                            init, // 初始化的数据变量
                            operat: [
                                [{
                                    text: '进场数据',
                                    url: init.access_url,
                                    method: 'open',
                                    auth: 'access',
                                    class: 'layui-btn layui-btn-xs layui-btn-success',
                                    extend: 'data-full="true"',
                                },],
                                'edit']
                        })
                     },
                    },
                ]],
                // operat: [
                //     [{
                //         text: '进场数据',
                //         url: init.getAccessData,
                //         method: 'open',
                //         auth: 'getAccessData',
                //         class: 'layui-btn layui-btn-xs layui-btn-success',
                //         extend: 'data-full="true"',
                //     },
                //     ],'edit' ]
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        access: function() {
            ea.listen();
        }
    };
    return Controller;
});